package main

func main()  {
	orDone := func(done,c <-chan interface{}) <-chan interface{} {
		valStream := make(chan interface{})
		go func() {
			for {
				select {
				case <-done:
					return
				case v,ok := <-c:
					if ok == false {
						return
					}
					select {
					case valStream <- v:
					case <-done:
					}
				}
			}
		}()
		return valStream
	}

	for val := range orDone(done,muchan) {
		//用val执行某些操作
	}

}
